<template>
    <div>
        <h1>会员等级列表</h1>
        <input type="button" value="添加会员等级" class="btn btn-primary" @click="add" />
        <table class="table table-bordered">
            <thead>
                <tr>
                    <td>Id</td>
                    <td>等级名称</td>
                </tr>
                <tr v-for="item in data" :key="item.id">
                    <td>{{item.id }}</td>
                    <td>{{item.leveName}}</td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import { onMounted,ref,reactive } from 'vue';
import axios from 'axios';

import { useRouter } from 'vue-router'


const router = useRouter()
let data :any= ref([])


const add = () => {
    router.push('/memberAdd')
}

//显示会员等级列表 
const getList = () => {
    axios({
        url: 'api/MemberLevel/GetMemberLeversList',
        method: 'get',
        
    })
    .then(res => {
        console.log(res);
        data.value = res.data
        
    })
    .catch(err => {

    })
}
//onMounted:生命周期钩子函数 ====文档就绪函数
onMounted(() => {
    getList();
})
</script>

<style scoped></style>